-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG][Python-fastapi] Ensure that authentication tokens are passed from the endpoint to implementation #20317
base: master
Are you sure you want to change the base?
Conversation
… implementation. example for endpoint file: ``` return await BasePetApi.subclasses[0]().add_pet(pet, token_petstore_auth=token_petstore_auth) ``` example of implementation file: ``` async def add_pet( self, pet: Annotated[Pet, Field(description="Pet object that needs to be added to the store")], token_petstore_auth: str ) -> Pet: ```
Revert accidental change
Correctly revert unintended change
ping @cbornet @tomplus @krjakbrjak @fa0311 @multani :-) |
@lmdevries thanks for the PR can you please PM me via Slack for some quick questions on this PR if you don't mind? https://join.slack.com/t/openapi-generator/shared_invite/zt-2wmkn4s8g-n19PJ99Y6Vei74WMUIehQA |
) -> User: | ||
"""""" | ||
... | ||
|
||
|
||
async def login_user( | ||
self, | ||
username: Annotated[str, Field(strict=True, description="The user name for login")], | ||
password: Annotated[StrictStr, Field(description="The password for login in clear text")], | ||
username: Annotated[str, Field(strict=True, description="The user name for login")], password: Annotated[StrictStr, Field(description="The password for login in clear text")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i prefer each parameter in a new line instead. what do you think?
@@ -68,7 +68,7 @@ async def {{operationId}}( | |||
{{#notes}}"""{{.}}""" | |||
{{/notes}}if not Base{{classname}}.subclasses: | |||
raise HTTPException(status_code=500, detail="Not implemented") | |||
return await Base{{classname}}.subclasses[0]().{{operationId}}({{#allParams}}{{>impl_argument}}{{^-last}}, {{/-last}}{{/allParams}}) | |||
return await Base{{classname}}.subclasses[0]().{{operationId}}({{#allParams}}{{>impl_argument}}{{^-last}}, {{/-last}}{{/allParams}}{{#authMethods}}{{#hasParams}}, {{/hasParams}}{{#authMethods}}token_{{name}}=token_{{name}}{{^-last}}, {{/-last}}{{/authMethods}}{{/authMethods}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if we should simply go with just {{name}} instead of token_{{name}}
also {{name}} may be in camel case, e.g. apiKey so we probably need to use the snakecase lambda in the mustache template to process {{name}}
… implementation.
Resolves issue: #20048
example for endpoint file:
return await BasePetApi.subclasses[0]().add_pet(pet, token_petstore_auth=token_petstore_auth)
example of implementation file:
@krjakbrjak
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming7.x.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)